package LawsonTransformJava.main;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import LawsonTransformJava.pgm.HR511;
import LawsonTransformJava.pgm.HR513;
import LawsonTransformJava.pgm.HR521;


public class HR521Main extends ClassMain {

	/**
	 * @author edavis
	 */
	
	private static final String OUTPUTLOCATION = "z:/conversions/dataload";
	
	public static void main(String[] args) {
		if (args.length!=1) {
			usage();
		}
		try {
			Thread thread1 = null;
			File outFile = new File(OUTPUTLOCATION + "/HSTLOADCSV_" + getDate() + "_" + Integer.parseInt(args[0].trim()));
			// TODO Create Error output logic
			File errFile = new File(OUTPUTLOCATION + "/HSTLOADCSV_ERROR_" + getDate() + "_" + Integer.parseInt(args[0].trim()));
			File convRpt = new File(OUTPUTLOCATION + "/HST_HR521TransformationReport_" + getDate() + "_" + Integer.parseInt(args[0].trim()) + ".txt");
	
			System.out.println("CLASSPATH=" + System.getenv("CLASSPATH"));
			System.out.println("WHERECLAUSE=" + System.getenv("WHERECLAUSE"));
			HR521 objDAO = null;
			objDAO = new HR521(outFile, errFile, convRpt, Integer.parseInt(args[0].trim()));
			
			if (objDAO!=null) {
				thread1 = new Thread(objDAO);
//				objDAO.setWhereClause(" WHERE HRHISTORY.EMPLOYEE=700434");
				thread1.start();
			}
		} catch (SQLException sqle) {
			// Could not write properties file
			// Could not create output file
			System.out.println("SQLException: " + sqle);
		}
	}

	private static void usage() {
		System.err.println("Usage - HR521Main YYYY");
		System.exit(1);
	}
}
